﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using PJ.Data;

namespace PJ.Business
{
    /// <summary>
    /// Item class
    /// </summary>
    /// <typeparam name="OD">Inner data object</typeparam>
    public abstract class Item<OD> : Entity<OD>, IItem
        where OD : IItemData
    {
        public Item(OD data)
            : base(data)
        {
        }
        public Item()
        {
        }
        public string Name
        {
            get
            {

                return ObjectData.Name;
            }
            set
            {
                if (ObjectData.Name != value)
                    ObjectData.Name = value;
            }
        }

        public string Alias
        {
            get
            {
                return ObjectData.AliasName;
            }
            set
            {
                if (ObjectData.AliasName != value)
                    ObjectData.AliasName = value;
            }
        }

        public override void CopyFrom(IBusinessObject data)
        {
            base.CopyFrom(data);
            IItem idata = data as IItem;
            if (idata != null)
            {
                this.Name = idata.Name;
                this.Alias = idata.Alias;
            }
        }
 
    }
}
